//package com.pubinfo.passbook.common.aspect;
//
//import com.pubinfo.passbook.common.annotation.JudgePermission;
//import com.pubinfo.passbook.common.entity.TSystemUser;
//import com.pubinfo.passbook.common.mapper.TSystemUserMapper;
//import com.pubinfo.passbook.common.model.vo.manage.RolePermissionVo;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.Resource;
//
//@Aspect
//@Slf4j
//@Configuration
//public class AspConfig {
//
//    @Resource
//    private TSystemUserMapper userMapper;
//
//    @Before(value = "@annotation(judgePermission)")
//    public void before(JudgePermission judgePermission) {
//        String permissionName = judgePermission.permission();
//        //权限验证名不可少
//        if (StringUtils.isBlank(permissionName)) {
//            throw new RuntimeException("权限验证注解错误");
//        }
//        TSystemUser user = (TSystemUser) SecurityUtils.getSubject().getPrincipal();
//        RolePermissionVo rolePermissionVo =
//                userMapper.selectUserPermissions(user.getUsername());
//        if (rolePermissionVo == null || !rolePermissionVo.getActives().contains(permissionName)) {
//            throw new AuthorizationException("无权限操作");
//        }
//    }
//}
